package cn.bmbanjia.zebra2024.apps.laddieAndroid.satoken;

import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpLogic;

public class StpLaddieAndroidUtil {

    public static final String TYPE = "laddie_android";

    public static final String current_key = "current_laddie_android_user";

    public static StpLogic stpLogic = new StpLogic(TYPE);

    public static void checkLogin() {
        stpLogic.checkLogin();
    }

    public static boolean isLogin() {
        return stpLogic.isLogin();
    }

    public static void login(LaddieAndroidCurrentUser laddieAndroidCurrentUser) {
        stpLogic.login(laddieAndroidCurrentUser.getLaddieId());
        SaSession session = stpLogic.getSession();
        session.set(current_key, laddieAndroidCurrentUser);
    }

    public static LaddieAndroidCurrentUser currentUser() {
        return (LaddieAndroidCurrentUser) stpLogic.getSession().get(current_key);
    }

    public static void logout() {
        stpLogic.logout();
    }

    public static void refreshCurrentUser(LaddieAndroidCurrentUser laddieAndroidCurrentUser) {
        SaSession session = stpLogic.getSession();
        session.set(current_key, laddieAndroidCurrentUser);
    }

}
